home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / DMTDEMOS / WRTSECT.DEM < prev   
Text File  |  1994-07-02  |  2KB  |  59 lines

  1. program WrtSectSample;
  2.  
  3.  {
  4.    This program uses the WrtSect procedure to fill a floppy disk sector
  5.    with the character 'A'.
  6.  }
  7.  
  8.  uses crt, DMT;
  9.  
  10.  var
  11.    SectorBuffer : array[ 1..512 ] of char;
  12.  
  13.    SectToWrite,
  14.    HeadToWrite,
  15.    CylToWrite   : word;
  16.  
  17.    DrvLetter    : char;
  18.  
  19. begin
  20.   fillchar( SectorBuffer, SizeOf( SectorBuffer ), 'A' );
  21.  
  22.   Color( 7, 0 );
  23.   clrscr;
  24.   writeln('Warning! : In general, it is safe to make read sectors operations from' );
  25.   writeln('           the disk, but this is not the case for write operations. If' );
  26.   writeln('           you write to a sector that has important information used by' );
  27.   writeln('           DOS, you can make the disk unusable. While you are experimen-' );
  28.   writeln('           ting with this routine practice only with an unused or empty' );
  29.   writeln('           FLOPPY disk, NEVER use a HARD DISK to practice.');
  30.   writeln( #7 );
  31.  
  32.   writeln( 'Press <Ctrl-Break> to abort, <Enter> to continue ');
  33.   readln;
  34.  
  35.   write( 'Select drive ( A-Z ) [ :]');
  36.   gotoxy( wherex - 3, wherey );
  37.   DrvLetter := upcase( readkey );
  38.   writeln( DrvLetter );
  39.  
  40.   HeadToWrite := 1;   { Write to disk side 1  }
  41.   CylToWrite  := 0;   { Write to disk track 0 }
  42.   SectToWrite := 1;   { Write to disk track 1 }
  43.  
  44.   WrtSect( DrvLetter, HeadToWrite, CylToWrite, SectToWrite, 1, addr( SectorBuffer ) );   { Call WrtSect procedure }
  45.  
  46.   if ( ErrFlag ) then
  47.     begin
  48.       writeln( #7 );
  49.       writeln( ShowError( GetErrCode ) );
  50.     end
  51.   else
  52.     begin
  53.       clrscr;
  54.       writeln;
  55.       writeln( 'Sector has been write, use READSECT to check.' );
  56.     end;
  57.  
  58.   GetEnter;
  59. end.